﻿using UnityEngine;

namespace HurricanePackage
{
    public abstract class UGUISubWnd<V> : BasicUGUIWnd<V>
    where V : BasicView
    {
        private Transform m_parentTransform;
        protected override Transform ParentTransform
        {
            get { return m_parentTransform; }
        }

        public UGUISubWnd(V _view)
        {
            _BandComponents(_view);
            //绑定父节点
            m_parentTransform = View.transform.parent;
        }

        protected override void InitWnd()
        {
            if(m_isInit)
                return;

            _OnInitDone();
            m_isInit = true;
        }

        public override void ShowWnd()
        {
            //如果还未初始化
            if(!m_isInit)
                InitWnd();

            m_gameObj?.SetActive(true);
            m_isShow = true;
            _OnShow();
        }

        public override void HideWnd()
        {
            if(!m_isInit || !m_isShow)
                return;


            m_gameObj?.SetActive(false);
            m_isShow = false;
            _OnHide();
        }

        public override void ResetWnd()
        {
            if (!m_isInit)
                return;

            _OnReset();
        }

        public override void DiscordWnd()
        {
            if (!m_isInit)
                return;

            HideWnd();

            _OnDiscord();
        }
    }
}